﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Web.Mvc;
using System.Web.Routing;
using Castle.ActiveRecord.Framework;
using System.Configuration;
using Castle.ActiveRecord;
using System.Reflection;
using MxTol.Managers;

namespace MxTol.UI
{
    // Note: For instructions on enabling IIS6 or IIS7 classic mode, 
    // visit http://go.microsoft.com/?LinkId=9394801
    public class MvcApplication : System.Web.HttpApplication
    {
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);

            // 初始化ORM框架
            IConfigurationSource source = ConfigurationManager.GetSection("activerecord") as IConfigurationSource;
            ActiveRecordStarter.Initialize(Assembly.Load("MxTol.Models"), source);

            // 初始化Manager数据库连接字符串 (ADO.NET)
            ManagerConfig.ConnectionString = ConfigurationManager.AppSettings["ConnectionString"];
        }
    }
}